package cn.rkylin.oms.ext.cainiao.shiporder.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;

import com.github.pagehelper.PageInfo;

import cn.rkylin.core.service.ApolloService;
import cn.rkylin.oms.aftersale.resend.service.IAfterSaleResendService;
import cn.rkylin.oms.ext.cainiao.shiporder.dao.ShiporderDAOImpl;
import cn.rkylin.oms.ext.cainiao.shiporder.dao.ShiporderSkuDAOImpl;
import cn.rkylin.oms.ext.cainiao.shiporder.vo.ShiporderSkuVO;
import cn.rkylin.oms.ext.cainiao.shiporder.vo.ShiporderVO;
import cn.rkylin.oms.order.service.IOrderService;
import cn.rkylin.oms.warehouse.stock.service.IStockService;

/**
 * 发货Service
 * 
 * @author 齐涛
 * @version 1.0
 * @created 28-9-2017 10:51:30
 */
@Repository(value = "cainiaoShiporderService")
public class ShiporderServiceImpl extends ApolloService implements IShiporderService {

    @Value("${oms.address}")
    private String omsAddres;

    @Value("${job.address}")
    private String jobAddress;

    @Autowired
    private ShiporderDAOImpl cainiaoShiporderDAO;

    @Autowired
    private ShiporderSkuDAOImpl cainiaoShiporderSkuDAO;

    @Autowired
    public IOrderService orderService;

    @Autowired
    public IAfterSaleResendService resendService;

    /**
     * 查询发货单列表
     * 
     * @param page
     *            页号
     * @param rows
     *            页大小
     * @param shiporderVO
     *            发货单VO
     * @return 发货单列表
     * @throws Exception
     *             异常
     */
    @SuppressWarnings("rawtypes")
    public PageInfo findByWhere(int page, int rows, ShiporderVO shiporderVO) throws Exception {
        PageInfo<ShiporderVO> shiporderVOList = findPage(page, rows, "pageSelectShiporderCaiNiao", shiporderVO);
        return shiporderVOList;
    }

    /**
     * 查询发货单信息
     * 
     * @param shiporderVO
     *            发货单VO
     * @return 发货单信息
     * @throws Exception
     *             异常
     */
    public ShiporderVO getShiporderInfo(ShiporderVO shiporderVO) throws Exception {
        return cainiaoShiporderDAO.getShiporderInfo(shiporderVO);
    }

    /**
     * 查询发货单信息
     * 
     * @param shiporderVO
     *            发货单VO
     * @return 发货单列表
     * @throws Exception
     *             异常
     */
    public List<ShiporderVO> getShiporderList(ShiporderVO shiporderVO) throws Exception {
        return cainiaoShiporderDAO.getShiporderList(shiporderVO);
    }

    /**
     * 查询发货单商品列表
     * 
     * @param shiporderGoodsVO
     *            发货单商品VO
     * @return 发货单信息
     * @throws Exception
     *             异常
     */
    public List<ShiporderSkuVO> selectShiporderSkuList(ShiporderSkuVO shiporderSkuVO) throws Exception {
        return cainiaoShiporderSkuDAO.selectShiporderSkuList(shiporderSkuVO);
    }

    @Override
    public int selectCount(Map<String, Object> params) throws Exception {
        return cainiaoShiporderDAO.selectCount(params);
    }
}
